// 云函数入口文件
const cloud = require('wx-server-sdk')
var rp = require('request-promise');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

// 云函数入口函数
exports.main = async(event, context) => {
  var options = {
    url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' + event.access_token,
    method: 'POST',
    body: {
      scene: event.id,
      page: 'pages/record_add/record_add',
    },
    encoding: null,
    json: true
  }
  return await rp(options).then(res => {
    return res
  })
}